package com.order.controller;

import com.comm.entity.Order;
import com.comm.entity.Product;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
@RequestMapping("order1")
public class OrderController1 {

    @Resource
    private RestTemplate restTemplate;
    @GetMapping
    public Order order(){
        // 根据商品的id 查询商品的价格  名字
        // Product localhost:8898/product/2
        Order order = new Order();
        order.setId(1);
        order.setOrdername("testOrder");

        Product forObject = restTemplate.getForObject("http://prodeuct/product/2", Product.class);
//        System.out.println(forObject);
        order.setProduct(forObject);
        System.out.println(order);
        return order;

    }
}
